package com.atmilan.quartz.sync.pull.buyer.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.atmilan.quartz.model.entity.buyer.BuyerProductSkuMerged;
import com.atmilan.quartz.sync.pull.buyer.mapper.BuyerProductSkuMergedMapper;
import com.atmilan.quartz.sync.pull.buyer.service.IBuyerProductSkuMergedService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hupeng
 * @since 2020-04-27
 */
@Service
@Transactional
public class BuyerProductSkuMergedServiceImpl extends ServiceImpl<BuyerProductSkuMergedMapper, BuyerProductSkuMerged>
        implements IBuyerProductSkuMergedService {
    @Autowired
    BuyerProductSkuMergedMapper buyerProductSkuMergedMapper;
    @Override
    public List<String> findAllSkuMerged(){

        List<Object> list = buyerProductSkuMergedMapper.selectObjs(new QueryWrapper<BuyerProductSkuMerged>().select(" concat(goods_id,'-',color,'-',size) "));
        return list == null? new ArrayList<String>():list.stream().map(o->o.toString()).collect(Collectors.toList());
    }

    @Override
    public void deleteAll() {
        buyerProductSkuMergedMapper.deleteAll();
    }
    
    @Override
    public void copyAll() {
        buyerProductSkuMergedMapper.deleteSkuMergedBack();
        buyerProductSkuMergedMapper.copySkuMergedBack();
    }
    
}
